home *** CD-ROM | disk | FTP | other *** search
/ Especial Multimedia / Especial Multimedia.iso / Multimed / Herra / TWK_VGA.ZIP / TWEAK.ASM < prev    next >
Assembly Source File  |  1997-09-14  |  5KB  |  230 lines

  1.  
  2. ; This program is in public domain
  3. ; Jussi Puttonen 22.7.1990
  4. ; modified 12.8.1990
  5.  
  6. .286
  7.  
  8. EMUL_MODE    equ    88    ; Paradise VGA 800x600
  9.  
  10.  
  11. code    segment    para public 'code'
  12.     assume    cs:code
  13.  
  14.  
  15. comment #
  16.  
  17. rows_on_screen    equ    600/16
  18. cols_on_screen    equ    800/8
  19.  
  20. ; tweaked register values
  21.                         ; 800 x 600 mode
  22.  
  23. crtc_regs    db    074h ; horisontal total time (0)
  24.         db    063h ; horisontal display end (1)
  25.         db    064h ; start horisontal blank (2)
  26.         db    097h ; end horisontal blank (3)
  27.         db    068h ; start horisontal retrace (4)
  28.         db    095h ; end horisontal retrace (5)
  29.  
  30.         db    086h ; vertical total (6)
  31.         db    0F0h ; overflow register (7)
  32.  
  33.         db    000h, 060h, 000h, 000h ; misc
  34.         db    000h, 000h, 002h, 085h
  35.         db    05Bh ; vertical retrace start (10)
  36.         db    08Dh ; vertical retrace end
  37.         db    057h    ; vertical display end
  38.         db     032h ; offset register
  39.         db    000h
  40.         db    060h ; start vertical blank
  41.         db    080h ; end vertical blank
  42.         db    0E3h ; mode control
  43.         db    0FFh
  44.  
  45. #
  46.  
  47. rows_on_screen    equ    600/16
  48. cols_on_screen    equ    800/8
  49.  
  50. ; tweaked register values
  51.                         ; 800 x 564 mode
  52.  
  53. crtc_regs    db    074h ; horisontal total time (0)
  54.         db    063h ; horisontal display end (1)
  55.         db    064h ; start horisontal blank (2)
  56.         db    097h ; end horisontal blank (3)
  57.         db    068h ; start horisontal retrace (4)
  58.         db    095h ; end horisontal retrace (5)
  59.  
  60.         db    062h ; vertical total (6)
  61.         db    0F0h ; overflow register (7)
  62.  
  63.         db    000h, 060h, 000h, 000h ; misc
  64.         db    000h, 000h, 002h, 061h
  65.         db    037h ; vertical retrace start (10)
  66.         db    089h ; vertical retrace end
  67.         db    033h    ; vertical display end
  68.         db     032h ; offset register
  69.         db    000h
  70.         db    03Ch ; start vertical blank
  71.         db    05Ch ; end vertical blank
  72.         db    0E3h ; mode control
  73.         db    0FFh
  74.  
  75. comment #
  76.  
  77. rows_on_screen    equ    564/16
  78. cols_on_screen    equ    752/8
  79.  
  80. ; tweaked register values
  81.                         ; 752 x 564 mode
  82.  
  83. crtc_regs    db    06Eh ; horisontal total time (0)
  84.         db    05Dh ; horisontal display end (1)
  85.         db    05Eh ; start horisontal blank (2)
  86.         db    091h ; end horisontal blank (3)
  87.         db    062h ; start horisontal retrace (4)
  88.         db    08Fh ; end horisontal retrace (5)
  89.  
  90.         db    062h ; vertical total (6)
  91.         db    0F0h ; overflow register (7)
  92.  
  93.         db    000h, 060h, 000h, 000h ; misc
  94.         db    000h, 000h, 002h, 061h
  95.         db    037h ; vertical retrace start (10)
  96.         db    089h ; vertical retrace end
  97.         db    033h    ; vertical display end
  98.         db     02Fh ; offset register
  99.         db    000h
  100.         db    03Ch ; start vertical blank
  101.         db    05Ch ; end vertical blank
  102.         db    0E3h ; mode control
  103.         db    0FFh
  104.  
  105. #
  106.  
  107.  
  108. VGA_SEGMENT       EQU   0A000h
  109.  
  110. OldVector    dd    0
  111.  
  112. Handler:    cmp    ax, EMUL_MODE
  113.         je    set_mode
  114.         cmp    ax, EMUL_MODE + 80h
  115.         je    set_mode
  116.     assume ds:nothing
  117.         jmp    [OldVector]
  118.  
  119. set_mode:
  120.     push    ds
  121.     push es
  122.     pusha
  123.     and    ax, 80h
  124.     or    ax, 12h
  125.     int    10h        ; set video mode to 12h
  126.  
  127.     push    cs
  128.     pop    ds
  129.  
  130.     assume ds:code
  131.  
  132.     mov    ax,1124h        ; load ROM 8*16 characters
  133.     mov    bx,0
  134.     mov    dh,0
  135.     mov    dl, rows_on_screen
  136.     int    10h
  137.  
  138.  
  139. ; this code is from FRACTINT, a public domain
  140. ; fractal program
  141.     mov    ax,40h            ; Video BIOS DATA area
  142.     mov    es,ax            ;  ...
  143.  
  144.     mov    ax, cols_on_screen
  145.     mov    word ptr es:[4ah],ax
  146.     mov    ax, cols_on_screen*rows_on_screen*2
  147.     mov    word ptr es:[4ch],ax
  148.  
  149.     mov    dx,word ptr es:[63h]    ; say, where's the 6845?
  150.     add    dx,6            ; locate the status register
  151. vrdly1:    in    al,dx            ; loop until vertical retrace is off
  152.     test    al,8            ;   ...
  153.     jnz    vrdly1            ;   ...
  154. vrdly2:    in    al,dx            ; now loop until it's on!
  155.     test    al,8            ;   ...
  156.     jz    vrdly2            ;   ...
  157.  
  158.     cli                ; turn off all interrupts
  159.     mov    dx,03c4h        ; Sequencer Synchronous reset
  160.     mov    ax,0100h        ; set sequencer reset
  161.     out    dx,ax
  162.     mov    dx,03c2h        ; Update Misc Output Reg
  163.     mov    al,0E7h
  164.     out    dx,al
  165.     mov    dx,03c4h        ; Sequencer Synchronous reset
  166.     mov    ax,0300h        ; clear sequencer reset
  167.     out    dx,ax
  168.  
  169.     mov    si, offset crtc_regs
  170.  
  171.     mov    dx,word ptr es:[63h]    ; say, where's the 6845?
  172.     mov    al,11h            ; deprotect registers 0-7
  173.     mov    ah,byte ptr [si+11h]
  174.     and    ah,7fh
  175.     out    dx,ax
  176.  
  177.     mov    cx,18h            ; update this many registers
  178.     mov    bx,00            ; starting with this one.
  179. crtcloop:
  180.     mov    al,bl            ; update this register
  181.     mov    ah,byte ptr [bx+si]    ; to this
  182.     out    dx,ax
  183.     inc    bx            ; ready for the next register
  184.     loop    crtcloop        ; (if there is a next register)
  185.  
  186. ; code quoted from FRACTINT ends here
  187.  
  188.     popa
  189.     pop    es
  190.     pop    ds
  191.     iret
  192.  
  193. pspseg    dw    0
  194.  
  195. start:
  196.     assume    ds:nothing
  197.     mov    pspseg, ds
  198. ;; Get Interrupt
  199.     mov    ax,3510h
  200.     int    21h
  201.     mov    word ptr OldVector.2,es
  202.     mov    word ptr OldVector,bx
  203.  
  204. ;; Set Interrupt
  205.  
  206.     mov    ax,2510h
  207.     mov    dx,seg Handler
  208.     mov    ds,dx
  209.     mov    dx,offset Handler
  210.     int    21h
  211.  
  212. ;; Now  T S R
  213.     mov    dx,offset start
  214.     mov    cl,4
  215.     shr    dx,cl
  216.     add    dx, 1
  217.     mov    ax, cs
  218.     add    dx, ax
  219.     sub    dx, pspseg
  220.     mov    ax,3100h
  221.     int    21h
  222.  
  223. code    ends
  224.  
  225. STACK   SEGMENT STACK  'STACK'
  226.         DB      256 DUP (?)
  227. STACK   ENDS
  228.  
  229.         end start
  230.